package com.pharmacy.mapper;


import com.github.pagehelper.Page;
import com.pharmacy.dto.OrdersPageSelectDto;
import com.pharmacy.dto.UpdateOrdersDto;
import com.pharmacy.entity.Orders;
import com.pharmacy.entity.WeeklyData;
import com.pharmacy.vo.TodayDate;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;

@Mapper
public interface OrdersMapper {


    /**
     * 添加订单
     * @param orders
     */
    @Insert("insert into orders(order_number, buyer_id, medicine, buy_date, price) values (#{orderNumber},#{buyerId},#{medicine},#{buyDate},#{price})")
    void addOrders(Orders orders);



    /**
     * 分页查询
     * @param ordersPageSelectDto
     * @return
     */
    Page<Orders> pageSelect(OrdersPageSelectDto ordersPageSelectDto);


    /**
     * 删除订单
     * @param orderId
     */
    @Delete("delete from orders where order_id = #{orderId}")
    void deleteOrders(Integer orderId);

    /**
     * 修改订单
     * @param updateOrdersDto
     */
    @Update("update orders set medicine = #{medicine},price = #{price} where order_number = #{orderNumber}")
    void updateOrders(UpdateOrdersDto updateOrdersDto);


    /**
     * 查询当天的订单
     * @param parsedDate
     * @return
     */
    TodayDate todayDate(LocalDate parsedDate);


    /**
     * 获取所有一周数据
     * @return
     */
    @Select("select * from weeklyData")
    WeeklyData weeklyData();


    /**
     * 修改周数据
     * @param
     */
    void updateWeeklyData(String Data);
}
